package com.tc.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tc.bean.T_MALL_PRODUCT;
import com.tc.bean.T_MALL_SKU;
import com.tc.bean.T_MALL_SKU_ATTR_VALUE;
import com.tc.mapper.SkuMapper;
@Service
public class SkuServiceImpl implements SkuServiceInf {
	@Autowired
	private SkuMapper skuMapper;
	
	@RequestMapping("save_sku")
	public void save_sku(T_MALL_SKU sku, T_MALL_PRODUCT spu, List<T_MALL_SKU_ATTR_VALUE> list_attr) {
		sku.setShp_id(spu.getId());
		//插入sku信息
		skuMapper.insert_sku(sku);
		//根据sku主键批量保存属性关系表
		Map<Object,Object> map = new HashMap<>();
		map.put("shp_id", sku.getShp_id());
		map.put("sku_id", sku.getId());
		map.put("list_av", list_attr);
		skuMapper.insert_sku_av(map);
	}
}
